/**
 * Created by alan on 2017/4/27.
 * 测站水位监测信息
 */
Ext.define('Admin.view.waterDispath.DdsDStzController', {
	extend: 'Ext.app.ViewController',
	alias: 'controller.ddsDStzController',

	init: function() {
		// Ext.Ajax.request({
		//   url: "test.json"
		// })
	},

	//steps下一步
	check: function() {
		var ddsDStzGrid = this.lookupReference('ddsDStzGrid');
		var store = ddsDStzGrid.getStore();
		var stcd = this.lookupReference('stcd').getValue();
		var startTm = this.lookupReference('startTm').getValue();
		var endTm = this.lookupReference('endTm').getValue();
		if(startTm > endTm) {
			Ext.Msg.alert('提示', '起始时间需要小于结束时间'); //这种方式非常常见的
			return;
		}
		store.getProxy().extraParams = {
			river: config.RIVER,
			stcd: stcd,
			startTm: (startTm == null ? startTm : Ext.Date.format(startTm, 'Y-m-d')),
			endTm: (endTm == null ? endTm : Ext.Date.format(endTm, 'Y-m-d'))
		};
		store.reload();
	},

	changeDate: function(tm) {
		var tmDate = new Date(tm);
		var y = tmDate.getFullYear();
		var m = tmDate.getMonth() + 1;
		m = m < 10 ? ('0' + m) : m;
		var d = tmDate.getDate();
		d = d < 10 ? ('0' + d) : d;
		var h = tmDate.getHours();
		h = h < 10 ? ('0' + h) : h;
		var minute = tmDate.getMinutes();
		minute = minute < 10 ? ('0' + minute) : minute;
		var second = tmDate.getSeconds();
		second = second < 10 ? ('0' + second) : second;
		return y + '-' + m + '-' + d + ' ' + h + ':' + minute + ':' + second;
	}
})